/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */

package com.kmxd.ams.app.convert;

import cn.hutool.core.util.ObjectUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 转换工具类
 *
 * @author ZuoLG
 */
@Component
@Slf4j
@AllArgsConstructor
public class DocConvertUtil {

  private Map<String, AbstractDocConvert> serviceMap;
  /** 如果找不到转换方式，默认使用pdf */
  private final String DEF_TRANSFER_TYPE = "aspose";

  /**
   * 获取转换实现
   *
   * @return
   */
  public AbstractDocConvert init(String transferType) {
    AbstractDocConvert convert = serviceMap.get(transferType);
    return ObjectUtil.isNull(convert) ? serviceMap.get(DEF_TRANSFER_TYPE) : convert;
  }
}
